#ifndef  FU_SYSTEM_H_
#define FU_SYSTEM_H_
#include <stdio.h>

#include "book.h"
#include "record.h"
#include "link_list.h"
#include "borrow_card.h"
#define SYS_FILE         ".\\bin\\sys.bin"
#define SYS_BOOK_DATA    ".\\bin\\book.bin"
#define SYS_RECORD_DATA  ".\\bin\\record.bin"
#define SYS_BORROWC_DATA ".\\bin\\borrowc.bin"

typedef struct
{
	unsigned borrwo_card_id;
	unsigned record_id;
	unsigned books_count;
	unsigned record_count;
	unsigned borrow_card_count;

	link_list m_books;
	link_list m_records;
	link_list m_borrow_cards;
}sys;

sys* load_system();

void save_and_close(sys* s);

void add_books(sys* s, fu_book* book);

void delete_book_by_id(sys* s, char const* c);

void delete_book_by_name(sys* s, char const* c);

link_list find_book_by_id(sys* s, char const* id);

link_list find_book_by_name(sys* s, char const* name);

void add_borrow_card(sys* s, borrow_card* card);

void remove_borrow_card(sys* s, unsigned id);

link_list find_borrow_card_name(sys* s, char const * name);
link_list find_borrow_card_id(sys* s, unsigned id);

void borrow_book(sys* s, char* bid, unsigned cid);
void return_book(sys* s, unsigned id,borrow_card* b);
#endif // ! FU_SYSTEM_H
